package com.c6906.vdam.monitor.mapper;

import com.c6906.vdam.monitor.model.Server;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ServerMapper {

    @Insert("INSERT INTO server(host_name, ip, ipv6) VALUES(#{hostName}, #{ip}, #{ipv6})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertServer(Server server);

    @Select("SELECT * FROM server WHERE host_name = #{hostName}")
    Server findByHostName(String hostName);

    @Select("SELECT * FROM server WHERE id = #{id}")
    Server findById(Long id);

    @Select("SELECT DISTINCT  host_name FROM server")
    List<String> findAllHostNames();
}
